package com.johnny.kotlinstudy.study1

/**
 *
 *  Created by Johnny on 2023/3/8
 *  Copyright © 2023年 大事件. All rights reserved.
 *
 *  Describe:
 */
fun main(args: Array<String>) {
    //todo map
    val userLis: List<String> = listOf("张三", "李四", "王五")
    val tipLis: List<String> = userLis.map { name -> "欢迎 $name" }
        .map { name -> "$name,加入我们这个大家庭" }
    println(userLis)
    println(tipLis)

    //todo flatMap 合并数组
    val result: List<Int> = listOf(
        listOf(1, 2, 3),
        listOf(4, 5, 6)
    ).flatten()
    println(result)

    //todo flatMap 将不同的集合合并成一个新集合
    val ages: List<Int> = listOf(18, 20, 30)
    val employeeAges: Map<String, Int> = userLis.zip(ages).toMap()
    println("张三的年龄${employeeAges["张三"]}岁")

}